# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Contributor: Stuart Cardall <developer@it-offshore.co.uk>
# Maintainer: Stuart Cardall <developer@it-offshore.co.uk>
pkgname=wrk
pkgver=4.2.0
pkgrel=1
pkgdesc="wrk is a modern HTTP benchmarking tool"
url="https://github.com/wg/wrk"
# requires -march=i586 to build on x86
arch="x86_64 aarch64"
license="Apache-2.0"
options="!check" # upstream does not provide tests
makedepends="openssl-dev>3 perl-dev linux-headers luajit-dev"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/wg/wrk/archive/$pkgver.tar.gz"

build() {
	# see https://github.com/wg/wrk/issues/310
	touch buildinf.h
	make -j1 -C "$builddir" \
		WITH_OPENSSL=/usr \
		WITH_LUAJIT=/usr CFLAGS+=$(pkg-config --cflags luajit)
}

package() {
	mkdir -p "$pkgdir"/usr/bin \
		"$pkgdir"/usr/share/licenses/$pkgname \
		"$pkgdir"/usr/share/doc/$pkgname/scripts

	install -m755 -D $pkgname "$pkgdir"/usr/bin/$pkgname
	install -m644 -D README.md "$pkgdir"/usr/share/doc/$pkgname/
	install -m644 -D LICENSE "$pkgdir"/usr/share/licenses/$pkgname/
	install -m644 -D NOTICE "$pkgdir"/usr/share/doc/$pkgname/
	install -m755 -D scripts/* "$pkgdir"/usr/share/doc/$pkgname/scripts/
}

sha512sums="
c356b1314f37b558f39f30d9a9c6a2a9c2f646eaf7c0cb4262325850922528148f89ccbe7c33390c87e40f8fef6fffd704e3cfe75a89e4e9b178101043fa038d  wrk-4.2.0.tar.gz
"
